#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
//缺省参数    默认参数
void Func(int a = 1)
{ 
	cout << a << endl;
}

//全缺省
void Func2(int a = 10, int b = 20, int c = 30)
{
	cout << "a=" << a << endl;
	cout << "b=" << b << endl;
	cout << "c=" << c << endl;
}
//半缺省--必须从右往左给缺省值
void Func3(int a, int b = 20, int c = 30)
{
	cout << "a=" << a << endl;
	cout << "b=" << b << endl;
	cout << "c=" << c << endl;
}

//不允许声明和定义同时给缺省参数
//声明和定义同时存在时
//声明给，定义不给
void Func4(int a = 4);
void Func4(int a)
{
	cout << a << endl;
}


//缺省参数的应用
typedef struct Stacl
{
	int* a;
	int top;
	int capacity;
}ST;
//缺省参数
void StackInit(ST* ps, int N = 4)
{
	ps->a = (int*)malloc(sizeof(int) * N);
	ps->top = 0;
	ps->capacity = N;
}
void StackPush(ST* ps, int n)
{
	;
}
int main()
{
	Func(2);
	Func();
	cout << endl;

	Func2();
	//显示传参
	Func2(1);//默认从从左往右传参
	Func2(1, 2);
	Func2(1, 2, 3);
	cout << endl;

	//至少传一个
	Func3(4);
	Func3(4, 5);
	Func3(4, 5, 6);

	ST st1;
	//知道插入多少个
	StackInit(&st1, 10);
	for (int i = 0; i < 10; i++)
	{
		StackPush(&st1, i);
	}
	//不知道插入多少个
	ST st2;
	StackInit(&st2);

	return 0;
}